package com.cloud.base.proxy;

import com.cloud.base.proxy.impl.OrderServiceImpl;
import org.springframework.cglib.core.DebuggingClassWriter;
import org.springframework.cglib.proxy.Enhancer;

public class CglibApplication {
    public static void main(String[] args) {
        System.setProperty(DebuggingClassWriter.DEBUG_LOCATION_PROPERTY, "D:\\Software-hty\\workspace\\springboot2\\src\\main\\java\\com\\cloud\\base\\proxy\\classes");
        MayiktCglibMethodInterceptor mayiktCglibMethodInterceptor = new MayiktCglibMethodInterceptor();
        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(OrderServiceImpl.class);
        enhancer.setCallback(mayiktCglibMethodInterceptor);
        OrderServiceImpl orderServiceImpl = (OrderServiceImpl) enhancer.create();
        String result = orderServiceImpl.addOrder("hty-cglib");
        System.out.println(result);
    }
}